<template>
  <div>
    <el-row class="m-b p-b">
      <div class="form-box">
        <SearchComp label-width="80px"
          :searchData="searchData"
          :searchForm="searchForm"
          :searchAction="searchHandle" />
      </div>
    </el-row>
    <div>
      <TableCompEle v-loading="loading"
        :tableData="tableData"
        :isSelect="false"
        :isPageIndex="true"
        :tableConfig="tableConfig"
        :queryParams="queryParams"
        @getPagination="getPagination"
        :isShowPage="true" />
    </div>
  </div>
</template>

<script>
// import { getOperationLogList } from '@/api/log.js'
// import { roleSelect } from '@/api/systemRole'

export default {
  name: 'LogUserLog',
  data() {
    return {
      loading: false,
      total: 0,
      pagination: {
        page: 1,
        size: 10
      },
      searchForm: {
        changeMethod: () => {
          this.queryParams.currentPage = 1
          this.paginationSize()
        },
        formData: [
          {
            type: 'Input',
            label: '操作人',
            prop: 'slOperator',
            clearable: true,
            placeholder: '请输入操作人',
            change: () => {
              this.paginationSize()
            }
          },
          {
            type: 'Select',
            label: '角色:',
            prop: 'roleId',
            filterable: true,
            clearable: true,
            placeholder: '请选择角色',
            options: [],
            sysKeys: { value: 'roleId', label: 'roleName' },
            change: () => this.paginationSize()
          }
        ]
      },
      searchHandle: [
        {
          label: '重置',
          handle: () => this.reset()
        }
      ],
      searchData: {
        slType: null,
        slOperator: null,
        slOperatorTime: null
      },
      tableData: [],
      tableConfig: [
        {
          prop: 'slOperatorTime',
          label: '操作时间'
        },
        {
          prop: 'slOperator',
          label: '操作人'
        },
        {
          prop: 'roleName',
          label: '操作人角色'
        },
        {
          prop: 'slType',
          label: '操作页面'
        },
        {
          prop: 'slMethod',
          label: '操作记录'
        },
        {
          prop: 'slContent',
          label: '操作内容'
        }
      ],
      queryParams: {
        total: 0,
        currentPage: 1,
        pageSize: 10
      }
    }
  },
  created() {
    this.initData()
    this.initRole()
  },
  methods: {
    getPagination() {
      this.initData()
    },
    initRole() {
      let res = {
        code: 200,
        message: '操作成功',
        data: [
          {
            roleId: 1,
            roleName: '超级管理员',
            roleKey: 'superadmin',
            roleSort: 1,
            dataScope: '1',
            menuCheckStrictly: true,
            deptCheckStrictly: true,
            status: '0',
            remark: '超级管理员',
            createTime: 1703674940000,
            flag: false,
            superAdmin: true,
            content: '平台最大管理员角色'
          },
          {
            roleId: 2,
            roleName: '主管机关',
            roleKey: 'common',
            roleSort: 2,
            dataScope: '2',
            menuCheckStrictly: true,
            deptCheckStrictly: true,
            status: '0',
            remark: '普通角色',
            createTime: 1703674940000,
            flag: false,
            superAdmin: false,
            content: '全面了解掌握科研设施与仪器共享资源状况和共享服务情况'
          },
          {
            roleId: 3,
            roleName: '大单位职能部门机关',
            roleKey: '1',
            roleSort: 3,
            dataScope: '1',
            menuCheckStrictly: true,
            deptCheckStrictly: true,
            status: '0',
            remark: '1',
            createTime: null,
            flag: false,
            superAdmin: false,
            content: '各大单位承担科研管理工作职责的机关部门'
          },
          {
            roleId: 4,
            roleName: '管理单位管理员',
            roleKey: '1',
            roleSort: 4,
            dataScope: '1',
            menuCheckStrictly: true,
            deptCheckStrictly: true,
            status: '0',
            remark: '1',
            createTime: null,
            flag: false,
            superAdmin: false,
            content: '直接管理使用重大科研基础设施和大型科研仪器的单位'
          },
          {
            roleId: 5,
            roleName: '设施仪器管理员',
            roleKey: '1',
            roleSort: 5,
            dataScope: '1',
            menuCheckStrictly: true,
            deptCheckStrictly: true,
            status: '0',
            remark: '1',
            createTime: null,
            flag: false,
            superAdmin: false,
            content: '负责共享资源的数据维护和共享服务的事务处理等工作'
          },
          {
            roleId: 6,
            roleName: '用户单位管理员',
            roleKey: '1',
            roleSort: 5,
            dataScope: '1',
            menuCheckStrictly: true,
            deptCheckStrictly: true,
            status: '0',
            remark: '1',
            createTime: null,
            flag: false,
            superAdmin: false,
            content: '主要使用管理单位共享资源的单位'
          },
          {
            roleId: 7,
            roleName: '平台中心管理员',
            roleKey: '1',
            roleSort: 5,
            dataScope: '1',
            menuCheckStrictly: true,
            deptCheckStrictly: true,
            status: '0',
            remark: '1',
            createTime: null,
            flag: false,
            superAdmin: false,
            content: '负责共享管理平台建设管和运行维护的军队单位'
          }
        ]
      }
      // roleSelect().then((res) => {
      this.roles = res.data
      this.searchForm.formData[1].options = res.data
      // }).catch(err => {
      //   console.log(err)
      // })
    },
    initData() {
      let res = {
        code: 200,
        total: 235,
        rows: [
          {
            id: 304485,
            slMethod: '修改部门',
            slResultCode: null,
            slUrl: null,
            slType: '共享信息管理',
            slOperator: 'admin',
            roleName: '超级管理员',
            slOperatorId: null,
            slOperatorTime: '2024-04-19 14:15:39',
            slContent: '修改部门：陆军研究院第一研究所 成功'
          },
          {
            id: 304484,
            slMethod: '修改部门',
            slResultCode: null,
            slUrl: null,
            slType: '共享信息管理',
            slOperator: 'admin',
            roleName: '超级管理员',
            slOperatorId: null,
            slOperatorTime: '2024-04-19 14:15:22',
            slContent: '查询发布列表 成功'
          },
          {
            id: 304483,
            slMethod: '修改部门',
            slResultCode: null,
            slUrl: null,
            slType: '共享信息管理',
            slOperator: 'admin',
            roleName: '超级管理员',
            slOperatorId: null,
            slOperatorTime: '2024-04-19 14:15:15',
            slContent: '修改部门：陆军研究院 成功'
          },
          {
            id: 304482,
            slMethod: '修改部门',
            slResultCode: null,
            slUrl: null,
            slType: '共享信息管理',
            slOperator: 'admin',
            roleName: '超级管理员',
            slOperatorId: null,
            slOperatorTime: '2024-04-19 14:15:00',
            slContent: '查询代码列表 成功'
          },
          {
            id: 304481,
            slMethod: '修改部门',
            slResultCode: null,
            slUrl: null,
            slType: '共享信息管理',
            slOperator: 'admin',
            roleName: '超级管理员',
            slOperatorId: null,
            slOperatorTime: '2024-04-19 14:14:56',
            slContent: '修改部门：陆军机关 成功'
          },
          {
            id: 304480,
            slMethod: '修改部门',
            slResultCode: null,
            slUrl: null,
            slType: '共享信息管理',
            slOperator: 'admin',
            roleName: '超级管理员',
            slOperatorId: null,
            slOperatorTime: '2024-04-19 14:14:50',
            slContent: '查询发布列表 成功'
          },
          {
            id: 304479,
            slMethod: '修改部门',
            slResultCode: null,
            slUrl: null,
            slType: '共享信息管理',
            slOperator: 'admin',
            roleName: '超级管理员',
            slOperatorId: null,
            slOperatorTime: '2024-04-19 14:14:44',
            slContent: '修改部门：陆军 成功'
          },
          {
            id: 304478,
            slMethod: '修改部门',
            slResultCode: null,
            slUrl: null,
            slType: '共享信息管理',
            slOperator: 'admin',
            roleName: '超级管理员',
            slOperatorId: null,
            slOperatorTime: '2024-04-19 14:14:20',
            slContent: '查询发布列表 成功'
          },
          {
            id: 304477,
            slMethod: '查询代码列表',
            slResultCode: null,
            slUrl: null,
            slType: '代码管理',
            slOperator: 'admin',
            roleName: '超级管理员',
            slOperatorId: null,
            slOperatorTime: '2024-04-19 14:11:41',
            slContent: '查询代码列表 成功'
          },
          {
            id: 304476,
            slMethod: '查询代码列表',
            slResultCode: null,
            slUrl: null,
            slType: '代码管理',
            slOperator: 'admin',
            roleName: '超级管理员',
            slOperatorId: null,
            slOperatorTime: '2024-04-19 14:11:35',
            slContent: '查询代码列表 成功'
          }
        ]
      }
      // this.loading = true
      // const params = {
      //   currentPage: this.queryParams.currentPage,
      //   pageSize: this.queryParams.pageSize,
      //   queryString: this.searchData
      // }
      // if (params.queryString.roleId !== undefined && params.queryString.roleId === '') {
      //   delete params.queryString.roleId
      // }
      // getOperationLogList(params).then((res) => {
      this.tableData = res.rows
      this.queryParams.total = res.total
      // })
      //   .finally(() => {
      //     // this.loading = false
      //   })
    },
    paginationSize() {
      this.queryParams.currentPage = 1
      this.initData()
    },
    reset() {
      this.searchData = {
        slType: null,
        slOperator: null,
        slOperatorTime: null
      }
      this.paginationSize()
    }
  }
}
</script>

<style></style>
